/*jadclipse*/// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) radix(10) lradix(10) 
// Source File Name:   ClientUI.java

package nc.ui.ic.ic644;

import java.awt.Insets;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Vector;
import javax.swing.JFrame;
import nc.ui.ic.pub.bill.GeneralBillHelper;
import nc.ui.ic.pub.bill.InvoInfoBYFormula;
import nc.ui.ic.pub.bill.query.ICMultiCorpQryClient;
import nc.ui.ic.pub.report.IcBaseReport;
import nc.ui.ic.pub.report.IcBaseReportComm;
import nc.ui.ml.NCLangRes;
import nc.ui.pub.ButtonObject;
import nc.ui.pub.ClientEnvironment;
import nc.ui.pub.FramePanel;
import nc.ui.pub.bill.BillItem;
import nc.ui.pub.bill.BillModel;
import nc.ui.pub.report.ReportBaseClass;
import nc.ui.pub.report.ReportItem;
import nc.ui.scm.pub.FreeVOParse;
import nc.vo.bd.CorpVO;
import nc.vo.ic.ic637.StockAgeItemVO;
import nc.vo.ic.ic644.FieldSumVO;
import nc.vo.ic.ic644.InOutSumHeaderVO;
import nc.vo.ic.ic644.InOutSumItemVO;
import nc.vo.ic.ic644.InOutSumVO;
import nc.vo.ic.pub.bill.QryConditionVO;
import nc.vo.ic.pub.lang.ResBase;
import nc.vo.pub.AggregatedValueObject;
import nc.vo.pub.BusinessException;
import nc.vo.pub.cquery.FldgroupVO;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pub.query.ConditionVO;
import nc.vo.pub.query.RefResultVO;
import nc.vo.scm.constant.ic.CONST;
import nc.vo.scm.pub.SCMEnv;
import nc.vo.sm.UserVO;

// Referenced classes of package nc.ui.ic.ic644:
//            InOutSumHelper

public class ClientUI extends IcBaseReport {

	public ClientUI() {
		ivjReportBaseClass = null;
		m_boQuery = new ButtonObject(NCLangRes.getInstance().getStrByID(
				"common", "UC001-0000006"), NCLangRes.getInstance().getStrByID(
				"4008report", "UPP4008report-000122"), 0, "\u67E5\u8BE2");
		m_aryButtonGroup = (new ButtonObject[] { m_boQuery });
		m_sCorpID = null;
		m_sCorpName = null;
		m_sUserID = null;
		m_sLogDate = null;
		m_sUserName = null;
		m_QueryConditionDlg = null;
		m_sQTempletID = "1111320640000200000B";
		m_iDispMode = 0;
		m_iMnyType = -1;
		m_bIsAstNumShow = true;
		m_sInOut = "I";
		m_voaDefaultFld = null;
		m_voaDefaultRI = null;
		m_baDefaultShow = new boolean[18];
		m_sPNodeCode = "40083608";
		m_voReport = null;
		m_sHeaderVOName = "nc.vo.ic.ic644.InOutSumHeaderVO";
		m_sItemVOName = "nc.vo.ic.ic644.InOutSumItemVO";
		m_sVOName = "nc.vo.ic.ic644.InOutSumVO";
		m_vBillItemHiddenID = null;
		m_IcBaseReportComm = null;
		initialize();
	}

	public ClientUI(FramePanel ff) {
		ivjReportBaseClass = null;
		m_boQuery = new ButtonObject(NCLangRes.getInstance().getStrByID(
				"common", "UC001-0000006"), NCLangRes.getInstance().getStrByID(
				"4008report", "UPP4008report-000122"), 0, "\u67E5\u8BE2");
		m_aryButtonGroup = (new ButtonObject[] { m_boQuery });
		m_sCorpID = null;
		m_sCorpName = null;
		m_sUserID = null;
		m_sLogDate = null;
		m_sUserName = null;
		m_QueryConditionDlg = null;
		m_sQTempletID = "1111320640000200000B";
		m_iDispMode = 0;
		m_iMnyType = -1;
		m_bIsAstNumShow = true;
		m_sInOut = "I";
		m_voaDefaultFld = null;
		m_voaDefaultRI = null;
		m_baDefaultShow = new boolean[18];
		m_sPNodeCode = "40083608";
		m_voReport = null;
		m_sHeaderVOName = "nc.vo.ic.ic644.InOutSumHeaderVO";
		m_sItemVOName = "nc.vo.ic.ic644.InOutSumItemVO";
		m_sVOName = "nc.vo.ic.ic644.InOutSumVO";
		m_vBillItemHiddenID = null;
		m_IcBaseReportComm = null;
		setFrame(ff);
		initialize();
	}

	public String[] getSums() {
		ReportItem riNow[] = getReportBaseClass().getBody_Items();
		String saSumCol[] = null;
		String sItemKey = null;
		Vector vSumCol = new Vector();
		if (riNow != null && riNow.length > 0) {
			for (int i = 0; i < riNow.length; i++) {
				if (riNow[i] == null)
					continue;
				sItemKey = riNow[i].getKey();
				if (sItemKey.indexOf("mny") >= 0
						|| sItemKey.indexOf("num") >= 0)
					vSumCol.addElement(sItemKey);
			}

		}
		if (vSumCol.size() > 0) {
			saSumCol = new String[vSumCol.size()];
			vSumCol.copyInto(saSumCol);
		}
		return saSumCol;
	}

	public ConditionVO[] filterCondVO(ConditionVO voaCond[], String saItemKey[]) {
		if (voaCond == null || saItemKey == null)
			return null;
		Vector vTempCond = new Vector();
		int j = 0;
		int len = saItemKey.length;
		for (int i = 0; i < voaCond.length; i++) {
			if (voaCond[i] == null)
				continue;
			for (j = 0; j < len
					&& (saItemKey[j] == null
							|| voaCond[i].getFieldCode() == null || !saItemKey[j]
							.trim().equals(voaCond[i].getFieldCode().trim())); j++)
				;
			if (j >= len)
				vTempCond.add(voaCond[i]);
		}

		ConditionVO voaRes[] = null;
		if (vTempCond.size() > 0) {
			voaRes = new ConditionVO[vTempCond.size()];
			vTempCond.copyInto(voaRes);
		}
		return voaRes;
	}

	public void filterCondVO2(ConditionVO voaCond[], String saItemKey[]) {
		if (voaCond == null || saItemKey == null)
			return;
		int j = 0;
		int len = saItemKey.length;
		for (int i = 0; i < voaCond.length; i++) {
			if (voaCond[i] == null)
				continue;
			for (j = 0; j < len; j++)
				if (saItemKey[j] != null
						&& voaCond[i].getFieldCode() != null
						&& saItemKey[j].trim().equals(
								voaCond[i].getFieldCode().trim())) {
					voaCond[i].setFieldCode("1");
					voaCond[i].setOperaCode("=");
					voaCond[i].setDataType(1);
					voaCond[i].setValue("1");
				}

		}

	}

	protected String getCalbody(ConditionVO voaCond[]) {
		String sCalbodyPK = null;
		try {
			int iCount = 0;
			if (voaCond != null) {
				for (int i = 0; i < voaCond.length; i++) {
					if (!"h.pk_calbody".equals(voaCond[i].getFieldCode().trim())
							|| voaCond[i].getRefResult() == null)
						continue;
					sCalbodyPK = voaCond[i].getRefResult().getRefPK();
					if (++iCount > 1)
						throw new Exception(NCLangRes.getInstance().getStrByID(
								"4008report", "UPP4008report-000093"));
				}
				
			}
		} catch (Exception e) {
			// TODO: handle exception
		}
		return sCalbodyPK;
	}

	protected void getCEnvInfo() {
		try {
			ClientEnvironment ce = ClientEnvironment.getInstance();
			try {
				m_sUserID = ce.getUser().getPrimaryKey();
			} catch (Exception e) {
			}
			try {
				m_sUserName = ce.getUser().getUserName();
			} catch (Exception e) {
			}
			try {
				m_sCorpID = ce.getCorporation().getPrimaryKey();
				SCMEnv.out((new StringBuilder()).append("---->corp id is ")
						.append(m_sCorpID).toString());
				m_sCorpName = ce.getCorporation().getUnitname();
				SCMEnv.out((new StringBuilder()).append("---->corp id is ")
						.append(m_sCorpName).toString());
			} catch (Exception e) {
			}
			try {
				if (ce.getDate() != null)
					m_sLogDate = ce.getDate().toString();
			} catch (Exception e) {
			}
		} catch (Exception e) {
		}
	}

	protected ICMultiCorpQryClient getConditionDlg() {
		if (m_QueryConditionDlg == null) {
			m_QueryConditionDlg = new ICMultiCorpQryClient(this, m_sUserID,
					m_sCorpID, getDefaultPNodeCode());
			m_QueryConditionDlg.setTempletID(m_sCorpID, getPNodeCode(),
					m_sUserID, null);
			m_QueryConditionDlg
					.initRefWhere(
							"ccustomerid",
							" and (custflag ='0' or custflag ='2') and (bd_cumandoc.frozenflag='N' OR bd_cumandoc.frozenflag='n'  OR bd_cumandoc.frozenflag IS NULL) ");
			m_QueryConditionDlg
					.initRefWhere(
							"cproviderid",
							" and (custflag ='1' or custflag ='3') and (bd_cumandoc.frozenflag='N' OR bd_cumandoc.frozenflag='n'  OR bd_cumandoc.frozenflag IS NULL) ");
			m_QueryConditionDlg
					.initRefWhere(
							"cvendorid",
							" and (custflag ='1' or custflag ='3') and (bd_cumandoc.frozenflag='N' OR bd_cumandoc.frozenflag='n'  OR bd_cumandoc.frozenflag IS NULL) ");
			m_QueryConditionDlg
					.initRefWhere("cinventorycode",
							" and bd_invbasdoc.discountflag='N' and bd_invbasdoc.laborflag='N' ");
			m_QueryConditionDlg
					.initRefWhere("b.cinventoryid",
							" and bd_invbasdoc.discountflag='N' and bd_invbasdoc.laborflag='N' ");
			m_QueryConditionDlg
					.initRefWhere(
							"ccostobject",
							" and  bd_produce.pk_invmandoc = bd_invmandoc.pk_invmandoc and bd_produce.sfcbdx = 'Y'  ");
			m_QueryConditionDlg.setRefInitWhereClause("cicalbodyid",
					"\u5E93\u5B58\u7EC4\u7EC7", "pk_corp=", "cicorpid");
			m_QueryConditionDlg.setRefInitWhereClause("cocalbodyid",
					"\u5E93\u5B58\u7EC4\u7EC7", "pk_corp=", "cocorpid");
			m_QueryConditionDlg.setRefInitWhereClause("ciwhid",
					"\u4ED3\u5E93\u6863\u6848", "bd_stordoc.pk_calbody=",
					"cicalbodyid");
			m_QueryConditionDlg.setRefInitWhereClause("cowhid",
					"\u4ED3\u5E93\u6863\u6848", "bd_stordoc.pk_calbody=",
					"cocalbodyid");
			m_QueryConditionDlg.setPowerRefsOfCorp("pk_corp", new String[] {
					"h.pk_calbody", "h.cwarehouseid", "b.cinventoryid",
					"invclasscode" }, null);
			m_QueryConditionDlg.setCorpRefs("cicorpid", new String[] {
					"cicalbodyid", "ciwhid" });
			m_QueryConditionDlg.setCorpRefs("cocorpid", new String[] {
					"cocalbodyid", "cowhid" });
			m_QueryConditionDlg.setFreeItem("vfree0", "b.cinventoryid");
			m_QueryConditionDlg.setLot("vbatchcode", "b.cinventoryid");
			String sThenClear[] = { "vfree0", "vbatchcode", "b.castunitid" };
			m_QueryConditionDlg.setAutoClear("b.cinventoryid", sThenClear);
			sThenClear = (new String[] { "cproviderid", "ccustomerid",
					"cdptid", "h.cwarehouseid", "b.cinventoryid" });
			m_QueryConditionDlg.setAutoClear("pk_corp", sThenClear);
			sThenClear = (new String[] { "vbatchcode" });
			m_QueryConditionDlg.setAutoClear("h.cwarehouseid", sThenClear);
			m_QueryConditionDlg.setCombox("qrylevel", new String[][] {
					new String[] {
							"1",
							NCLangRes.getInstance().getStrByID("common",
									"UC000-0001439") },
					new String[] {
							"2",
							NCLangRes.getInstance().getStrByID("4008report",
									"UPP4008report-000155") },
					new String[] {
							"3",
							NCLangRes.getInstance().getStrByID("4008report",
									"UPP4008report-000156") },
					new String[] {
							"4",
							NCLangRes.getInstance().getStrByID("4008report",
									"UPP4008report-000157") },
					new String[] { "6", ResBase.get641QueryCond1() },
					new String[] {
							"5",
							NCLangRes.getInstance().getStrByID("4008report",
									"UPP4008report-000158") },
					new String[] { "7", ResBase.get641QueryCond2() },
					new String[] {
							"0",
							NCLangRes.getInstance().getStrByID("common",
									"UC000-0001443") } });
			m_QueryConditionDlg.setCombox("splitfield", new String[][] {
					new String[] {
							"0",
							NCLangRes.getInstance().getStrByID("common",
									"UC000-0004165") },
					new String[] {
							"1",
							NCLangRes.getInstance().getStrByID("common",
									"UC000-0000275") },
					new String[] {
							"2",
							NCLangRes.getInstance().getStrByID("common",
									"UC000-0000153") },
					new String[] {
							"3",
							NCLangRes.getInstance().getStrByID("common",
									"UC000-0004064") },
					new String[] {
							"4",
							NCLangRes.getInstance().getStrByID("SCMCOMMON",
									"UPPSCMCommon-000298") },
					new String[] {
							"5",
							NCLangRes.getInstance().getStrByID("common",
									"UC001-0000003") },
					new String[] {
							"6",
							NCLangRes.getInstance().getStrByID("common",
									"UC000-0002209") },
					new String[] {
							"7",
							NCLangRes.getInstance().getStrByID("common",
									"UC000-0000807") } });
			m_QueryConditionDlg.setCombox("cbilltypecode", CONST
					.getIC_BILLTYPEIN());
			m_QueryConditionDlg.setDefaultValue("dbilldatefrom", null,
					getDefaultStartDate().toString());
			m_QueryConditionDlg.setDefaultValue("dbilldateto", null,
					getDefaultEndDate().toString());
			m_QueryConditionDlg.hideNormal();
		}
		return m_QueryConditionDlg;
	}

	protected UFDate getDefaultEndDate() {
		if (m_sLogDate == null || m_sLogDate.trim().length() != 10)
			return new UFDate("2001-01-01");
		else
			return new UFDate(new String((new StringBuilder()).append(
					m_sLogDate.substring(0, 8)).append(
					new Integer((new UFDate(m_sLogDate)).getDaysMonth()))
					.toString()));
	}

	public String getDefaultPNodeCode() {
		return m_sPNodeCode;
	}

	protected UFDate getDefaultStartDate() {
		if (m_sLogDate == null || m_sLogDate.trim().length() != 10)
			return new UFDate("2001-01-01");
		else
			return new UFDate(new String((new StringBuilder()).append(
					m_sLogDate.substring(0, 8)).append("01").toString()));
	}

	public ReportBaseClass getReportBaseClass() {
		if (ivjReportBaseClass != null)
			return ivjReportBaseClass;//break MISSING_BLOCK_LABEL_117;
		ivjReportBaseClass = new ReportBaseClass();
		ivjReportBaseClass.setName("ReportBaseClass");
		try {
			ivjReportBaseClass.setTempletID(m_sCorpID, getPNodeCode(),
					m_sUserID, null);
		} catch (Exception e) {
			showErrorMessage(NCLangRes.getInstance().getStrByID("SCMCOMMON",
					"UPPSCMCommon-000019"));
			return ivjReportBaseClass;
		}
		try {
			ivjReportBaseClass.setRowNOShow(true);
			ivjReportBaseClass.setTatolRowShow(true);
			nc.ui.pub.bill.BillData bd = ivjReportBaseClass.getBillData();
			if (bd == null) {
				SCMEnv.out("--> billdata null.");
				return ivjReportBaseClass;
			}
		} catch (Throwable ivjExc) {
			handleException(ivjExc);
		}
		return ivjReportBaseClass;
	}

	protected ReportItem getReportItem(String sKey, String sTitle) {
		ReportItem biAddItem = new ReportItem();
		biAddItem.setName(sTitle);
		biAddItem.setKey(sKey);
		biAddItem.setDataType(2);
		biAddItem.setDecimalDigits(4);
		biAddItem.setLength(80);
		biAddItem.setWidth(80);
		biAddItem.setEnabled(false);
		if (sKey.startsWith(StockAgeItemVO.SPREV_dynamic_mny)
				|| sKey.startsWith(StockAgeItemVO.SPREV_dynamic_planmny)
				|| sKey.startsWith(StockAgeItemVO.SPREV_dynamic_num))
			biAddItem.setTatol(true);
		biAddItem.setShow(true);
		biAddItem.setPos(1);
		if (sKey != null)
			if (sKey.indexOf("mny") >= 0)
				biAddItem.setDecimalDigits(m_iaScale[4]);
			else if (sKey.indexOf("astnum") >= 0
					|| sKey.indexOf("assistnum") >= 0)
				biAddItem.setDecimalDigits(m_iaScale[1]);
			else
				biAddItem.setDecimalDigits(m_iaScale[0]);
		return biAddItem;
	}

	public String getTitle() {
		if (getReportBaseClass().getReportTitle() != null)
			return getReportBaseClass().getReportTitle();
		else
			return NCLangRes.getInstance().getStrByID("4008report",
					"UPP4008report-000094");
	}

	protected ArrayList getWarehouse(ConditionVO voaCond[]) {
		ArrayList alRet = new ArrayList();
		if (voaCond != null) {
			for (int i = 0; i < voaCond.length; i++) {
				SCMEnv.out("@#1");
				if ("h.cwarehouseid".equals(voaCond[i].getFieldCode())) {
					if (voaCond[i].getRefResult() == null) {
						SCMEnv.out("@#3");
						continue;
					}
					alRet.add(voaCond[i].getRefResult().getRefPK());
				}
				SCMEnv.out("@#2");
			}

		}
		return alRet;
	}

	protected void handleException(Throwable exception) {
		SCMEnv
				.out("--------- \u672A\u6355\u6349\u5230\u7684\u5F02\u5E38 ---------");
		SCMEnv.error(exception);
	}

	protected void initialize() {
		try {
			m_btnPrint.setVisible(false);
			m_btnPreview.setVisible(false);
			setButtons(getButtonArray(m_aryButtonGroup));
			getCEnvInfo();
			setName("ClientUI");
			setSize(774, 419);
			add(getReportBaseClass(), "Center");
			setTotalAst(true);
		} catch (Throwable ivjExc) {
			handleException(ivjExc);
		}
		if (getReportBaseClass().getHeadItem("dbilldatefrom") != null)
			getReportBaseClass().getHeadItem("dbilldatefrom").setEnabled(false);
		if (getReportBaseClass().getHeadItem("dbilldateto") != null)
			getReportBaseClass().getHeadItem("dbilldateto").setEnabled(false);
		try {
			getReportBaseClass().setMaxLenOfHeadItem("qrycondition", 500);
			getReportBaseClass().setMaxLenOfHeadItem("unitname", 100);
		} catch (Exception e) {
		}
		try {
			getReportBaseClass().hideColumn(new String[] { "nplannedprice" });
			getReportBaseClass().hideColumn(new String[] { "nprice" });
		} catch (Exception e) {
		}
		initSysParam();
		setScale();
		getHiddenBillItem();
		m_iDispMode = 0;
		m_voaDefaultRI = getReportBaseClass().getBody_Items();
		if (m_voaDefaultRI != null) {
			for (int col = 0; col < m_voaDefaultRI.length; col++) {
				if (m_voaDefaultRI[col] == null
						|| m_voaDefaultRI[col].getKey() == null)
					continue;
				for (int ik = 0; ik < m_saAllCol.length; ik++)
					if (m_saAllCol[ik] != null
							&& m_saAllCol[ik].equals(m_voaDefaultRI[col]
									.getKey().trim()))
						m_baDefaultShow[ik] = m_voaDefaultRI[col].isShow();

			}

		}
		m_voaDefaultFld = getReportBaseClass().getFieldGroup();
		setBtnState();
	}

	protected void initSysParam() {
		ArrayList alRetData = null;
		String saParam[] = { "BD501", "BD502", "BD503", "BD504", "BD301" };
		ArrayList alAllParam = new ArrayList();
		ArrayList alParam = new ArrayList();
		alParam.add(m_sCorpID);
		alParam.add(saParam);
		alAllParam.add(alParam);
		alAllParam.add(m_sUserID);
		try {
			alRetData = (ArrayList) GeneralBillHelper.queryInfo(new Integer(11),alAllParam);
		} catch (Exception e) 
		{
		}
		if (alRetData == null || alRetData.size() < 2) {
			SCMEnv.out("\u521D\u59CB\u5316\u53C2\u6570\u9519\u8BEF\uFF01");
			return;
		}
		try {
			String saParamValue[] = (String[]) (String[]) alRetData.get(0);
			if (saParamValue != null && saParamValue.length > 4) {
				m_iaScale[0] = Integer.parseInt(saParamValue[0]);
				m_iaScale[1] = Integer.parseInt(saParamValue[1]);
				m_iaScale[2] = Integer.parseInt(saParamValue[2]);
				m_iaScale[3] = Integer.parseInt(saParamValue[3]);
				m_iaScale[4] = Integer.parseInt(saParamValue[4]);
			}
		} catch (Exception e) {
			SCMEnv.out((new StringBuilder()).append("can not get para").append(
					e.getMessage()).toString());
			if (e instanceof BusinessException)
				showErrorMessage(e.getMessage());
		}
		return;
	}

	public static void main(String args[]) {
		try {
			JFrame frame = new JFrame();
			ClientUI aClientUI = new ClientUI();
			frame.setContentPane(aClientUI);
			frame.setSize(aClientUI.getSize());
			frame.addWindowListener(new WindowAdapter() {

				public void windowClosing(WindowEvent e) {
					System.exit(0);
				}

			});
			frame.show();
			Insets insets = frame.getInsets();
			frame.setSize(frame.getWidth() + insets.left + insets.right, frame
					.getHeight()
					+ insets.top + insets.bottom);
			frame.setVisible(true);
		} catch (Throwable exception) {
			SCMEnv
					.out("nc.ui.pub.ToftPanel \u7684 main() \u4E2D\u53D1\u751F\u5F02\u5E38");
			SCMEnv.error(exception);
		}
	}

	public void onButtonClicked(ButtonObject bo) {
		if (bo == m_boQuery) {
			onQuery(true);
			setBtnState();
		} else {
			super.onButtonClicked(bo);
		}
	}

	public void onQuery(boolean bQuery) {
		if (bQuery || !m_bEverQry) {
			getConditionDlg().showModal();
			m_bEverQry = true;
		} else {
			getConditionDlg().onButtonConfig();
		}
		String sWhereSQL = null;
		if (getConditionDlg().isCloseOK())
			sWhereSQL = getConditionDlg().getWhereSQL();
		else
			return;
		String corps[];
		corps = getConditionDlg().getSelectedCorpIDs();
		if (corps == null || corps.length < 0) {
			showWarningMessage(NCLangRes.getInstance().getStrByID("4008report",
					"UPP4008report-000186"));
			onQuery(true);
			return;
		}
		ConditionVO voaCond[];
		long lTimeAll;
		UFDate dtStartDate;
		UFDate dtEndDate;
		String sQryLevel;
		String sSplitField;
		String sOnlySignedBill;
		String sSplitwarehouse;
		String providernotnull;
		String sSplitProvider;
		String sInvClassLevel;
		String sBilltypeCode;
		String sSearchBYRdcl;
		boolean bICorp;
		boolean bOCorp;
		boolean bICalbody;
		boolean bOCalbody;
		boolean bIWh;
		boolean bOWh;
		String cothercorpid;
		String cothercalid;
		String cotherwhid;
		setDlgSubTotal(null);
		voaCond = getConditionDlg().getConditionVO();
		lTimeAll = System.currentTimeMillis();
		dtStartDate = null;
		dtEndDate = null;
		sQryLevel = "1";
		sSplitField = "1";
		sOnlySignedBill = "N";
		sSplitwarehouse = "N";
		providernotnull = "N";
		sSplitProvider = "N";
		sInvClassLevel = "2";
		StringBuffer sbMsg = new StringBuffer();
		String sCorpID = null;
		String sCorpName = null;
		sBilltypeCode = null;
		String sFieldCode = null;
		sSearchBYRdcl = "N";
		bICorp = false;
		bOCorp = false;
		bICalbody = false;
		bOCalbody = false;
		bIWh = false;
		bOWh = false;
		cothercorpid = null;
		cothercalid = null;
		cotherwhid = null;
		String sClassCode = null;
		if (voaCond != null) {
			for (int i = 0; i < voaCond.length; i++) {
				if (voaCond[i] == null || voaCond[i].getFieldCode() == null)
					continue;
				sFieldCode = voaCond[i].getFieldCode().trim();
				if ("like".equals(voaCond[i].getOperaCode()))
					if ("dept.deptcode".equals(sFieldCode))
						voaCond[i].setValue((new StringBuilder()).append(
								voaCond[i].getValue()).append("%").toString());
					else
						voaCond[i].setValue((new StringBuilder()).append("%")
								.append(voaCond[i].getValue()).append("%")
								.toString());
				if ("pk_corp".equals(sFieldCode)) {
					if (voaCond[i].getRefResult() != null) {
						sCorpID = voaCond[i].getRefResult().getRefPK();
						sCorpName = voaCond[i].getRefResult().getRefName();
					}
					continue;
				}
				if ("cicorpid".equals(sFieldCode)) {
					if ("=".equals(voaCond[i].getOperaCode().trim())) {
						RefResultVO vo = voaCond[i].getRefResult();
						cothercorpid = vo != null ? vo.getRefName() : null;
						bICorp = true;
					}
					voaCond[i].setFieldCode("cothercorpid");
					continue;
				}
				if ("cocorpid".equals(sFieldCode)) {
					if ("=".equals(voaCond[i].getOperaCode().trim())) {
						RefResultVO vo = voaCond[i].getRefResult();
						cothercorpid = vo != null ? vo.getRefName() : null;
						bOCorp = true;
					}
					voaCond[i].setFieldCode("cothercorpid");
					continue;
				}
				if ("cicalbodyid".equals(sFieldCode)) {
					if ("=".equals(voaCond[i].getOperaCode().trim())) {
						cothercalid = voaCond[i].getValue();
						RefResultVO vo = voaCond[i].getRefResult();
						cothercalid = vo != null ? vo.getRefName() : null;
						bICalbody = true;
					}
					voaCond[i].setFieldCode("cothercalbodyid");
					continue;
				}
				if ("cocalbodyid".equals(sFieldCode)) {
					if ("=".equals(voaCond[i].getOperaCode().trim())) {
						cothercalid = voaCond[i].getValue();
						RefResultVO vo = voaCond[i].getRefResult();
						cothercalid = vo != null ? vo.getRefName() : null;
						bOCalbody = true;
					}
					voaCond[i].setFieldCode("cothercalbodyid");
					continue;
				}
				if ("ciwhid".equals(sFieldCode)) {
					if ("=".equals(voaCond[i].getOperaCode().trim())) {
						cotherwhid = voaCond[i].getValue();
						RefResultVO vo = voaCond[i].getRefResult();
						cotherwhid = vo != null ? vo.getRefName() : null;
						bIWh = true;
					}
					voaCond[i].setFieldCode("cotherwhid");
					continue;
				}
				if ("cowhid".equals(sFieldCode)) {
					if ("=".equals(voaCond[i].getOperaCode().trim())) {
						cotherwhid = voaCond[i].getValue();
						RefResultVO vo = voaCond[i].getRefResult();
						cotherwhid = vo != null ? vo.getRefName() : null;
						bOWh = true;
					}
					voaCond[i].setFieldCode("cotherwhid");
					continue;
				}
				if ("dbilldatefrom".equals(voaCond[i].getFieldCode().trim())) {
					if (voaCond[i].getValue() != null
							&& voaCond[i].getValue().trim().length() > 0)
						dtStartDate = new UFDate(voaCond[i].getValue().trim());
					continue;
				}
				if ("dbilldateto".equals(voaCond[i].getFieldCode().trim())) {
					if (voaCond[i].getValue() != null
							&& voaCond[i].getValue().trim().length() > 0)
						dtEndDate = new UFDate(voaCond[i].getValue().trim());
					continue;
				}
				if ("qrylevel".equals(voaCond[i].getFieldCode().trim())) {
					if (voaCond[i].getRefResult() != null)
						sQryLevel = voaCond[i].getRefResult().getRefPK();
					continue;
				}
				if ("splitfield".equals(voaCond[i].getFieldCode().trim())) {
					if (voaCond[i].getRefResult() != null)
						sSplitField = voaCond[i].getRefResult().getRefPK();
					continue;
				}
				if ("cbilltypecode".equals(voaCond[i].getFieldCode().trim())) {
					if (voaCond[i].getRefResult() != null)
						sBilltypeCode = voaCond[i].getRefResult().getRefPK();
					continue;
				}
				if ("onlysignedbill".equals(voaCond[i].getFieldCode().trim())) {
					sOnlySignedBill = voaCond[i].getValue();
					if (sOnlySignedBill != null
							&& sOnlySignedBill.trim().toUpperCase().startsWith(
									"Y"))
						sOnlySignedBill = "Y";
					else
						sOnlySignedBill = "N";
					continue;
				}
				if ("splitwarehouse".equals(sFieldCode)) 
				{
					sSplitwarehouse = voaCond[i].getValue();
					if (sSplitwarehouse != null
							&& sSplitwarehouse.trim().toUpperCase().startsWith(
									"Y"))
						sSplitwarehouse = "Y";
					continue;
				}
				if ("splitprovider".equals(sFieldCode)) 
				{
					sSplitProvider = voaCond[i].getValue();
					if (sSplitProvider != null
							&& sSplitProvider.trim().toUpperCase().startsWith(
							"Y"))
						sSplitProvider = "Y";
					continue;
				}
				if ("providernotnull".equals(sFieldCode)) 
				{
					providernotnull = voaCond[i].getValue();
					if (providernotnull != null
							&& providernotnull.trim().toUpperCase().startsWith(
							"Y"))
						providernotnull = "Y";
					continue;
				}
				if ("invclasslev".equals(sFieldCode)) {
					sInvClassLevel = voaCond[i].getValue();
					continue;
				}
				if ("invclasscode".equals(sFieldCode)
						&& voaCond[i].getValue() != null) {
					if ("=".equals(voaCond[i].getOperaCode().trim())) {
						sClassCode = voaCond[i].getValue();
						voaCond[i].setOperaCode(" LIKE ");
						voaCond[i].setValue((new StringBuilder()).append(
								voaCond[i].getValue()).append("%").toString());
					}
					voaCond[i].setFieldCode("invcl.invclasscode");
					continue;
				}
				if ("rdcl.rdcode".equals(sFieldCode)
						&& voaCond[i].getValue() != null)
					sSearchBYRdcl = "Y";
			}

		}
		if (sQryLevel == null || sQryLevel.trim().length() == 0)
			sQryLevel = "1";
		else if (sQryLevel.trim().charAt(0) > '7'
				|| sQryLevel.trim().charAt(0) < '0')
			sbMsg.append(NCLangRes.getInstance().getStrByID("4008report",
					"UPP4008report-000095"));
		if (sSplitField == null || sSplitField.trim().length() == 0)
			sSplitField = "1";
		if (dtStartDate == null)
			dtStartDate = getDefaultStartDate();
		if (dtEndDate == null)
			dtEndDate = getDefaultEndDate();
		if (dtStartDate.after(dtEndDate))
			sbMsg.append(NCLangRes.getInstance().getStrByID("4008report",
					"UPP4008report-000041"));
		if (sbMsg.toString().length() > 0) {
			showErrorMessage(sbMsg.toString());
			return;
		}
		ArrayList alRet = null;
		InOutSumVO voFA;
		m_bIsAstNumShow = false;
		if ("4".equals(sQryLevel) || "5".equals(sQryLevel)
				|| "6".equals(sQryLevel) || "7".equals(sQryLevel))
			m_bIsAstNumShow = true;
		QryConditionVO voCond = new QryConditionVO();
		voCond.setParam(0, corps);
		voCond.setParam(1, sQryLevel);
		voCond.setParam(2, sOnlySignedBill);
		voCond.setParam(3, sSplitField);
		voCond.setParam(4, dtStartDate);
		voCond.setParam(5, dtEndDate);
		voCond.setParam(6, sInvClassLevel);
		voCond.setParam(7, m_sInOut);
		voCond.setParam(8, getCalbody(voaCond));
		voCond.setParam(9, getWarehouse(voaCond));
		voCond.setParam(10, sBilltypeCode);
		voCond.setParam(20, voaCond);
		voCond.setParam(21, sSearchBYRdcl);
		voCond.setParam(22, sSplitProvider);
		voCond.setParam(23, sSplitwarehouse);
		voCond.setParam(24, providernotnull);
		String saItemKey[] = { "pk_corp", "qrylevel", "splitfield",
				"onlysignedbill","splitprovider","splitwarehouse","providernotnull", "dbilldatefrom", "dbilldateto",
				"invclasslev", "cbilltypecode" };
		filterCondVO2(voaCond, saItemKey);
		String sSpecialDB = "";
		if (bOCorp || bOCalbody || bOWh)
			sSpecialDB = " and (cbilltypecode='4E') ";
		if (bICorp || bICalbody || bIWh)
			sSpecialDB = " and (cbilltypecode='4Y') ";
		voCond.setQryCond((new StringBuilder()).append(
				getConditionDlg().getWhereSQL(voaCond)).append(sSpecialDB)
				.toString());
		long lTime = System.currentTimeMillis();
		try {
			alRet = InOutSumHelper.queryInOutSum(voCond);
		} catch (Exception e) {
		}
		showTime(lTime, "\u67E5\u8BE2");
		voFA = new InOutSumVO();
		InOutSumHeaderVO voHead = new InOutSumHeaderVO();
		voHead.setDbilldatefrom(dtStartDate);
		voHead.setDbilldateto(dtEndDate);
		voHead.setQrycondition(getConditionDlg().getChText());
		getReportBaseClass().setBody_Items(m_voaDefaultRI);
		getReportBaseClass().setFieldGroup(m_voaDefaultFld);
		setShowColByQryLevel(sQryLevel.charAt(0));
		setShowGenSumCol(false);
		getReportBaseClass().setHeadDataVO(voHead);
		if (alRet == null || alRet.size() == 0 || alRet.get(0) == null) {
			getReportBaseClass().getBillModel().clearBodyData();
			showHintMessage(NCLangRes.getInstance().getStrByID("4008report",
					"UPP4008report-000042"));
			return;
		}
		try {
			InOutSumItemVO voaF[] = (InOutSumItemVO[]) (InOutSumItemVO[]) alRet
					.get(0);
			char cGroupType = sSplitField.charAt(0);
			if (voaF != null) {
				for (int i = 0; i < voaF.length; i++) {
					voaF[i].setAttributeValue("cicorpname", cothercorpid);
					voaF[i].setAttributeValue("cocorpname", cothercorpid);
					voaF[i].setAttributeValue("cicalbodyname", cothercalid);
					voaF[i].setAttributeValue("cocalbodyname", cothercalid);
					voaF[i].setAttributeValue("ciwhname", cotherwhid);
					voaF[i].setAttributeValue("cowhname", cotherwhid);
				}

			}
			setReportData(cGroupType, voaF, sQryLevel);
			m_voReport = voFA;
			m_voReport.setParentVO(getReportBaseClass().getHeadDataVO());
			m_voReport.setChildrenVO(getReportBaseClass().getBodyDataVO());
			getReportBaseClass().updateValue();
			calculateTotal();
			showTime(lTimeAll, "\u5168\u90E8\u65F6\u95F4");
			showHintMessage(NCLangRes.getInstance().getStrByID("SCMCOMMON",
					"UPPSCMCommon-000133"));
		} /*catch (BusinessException be) {
			showErrorMessage(be.getMessage());
		}*/ catch (Exception e) {
			handleException(e);
			showErrorMessage((new StringBuilder()).append(
					NCLangRes.getInstance().getStrByID("4008report",
							"UPP4008report-000004")).append(e.getMessage())
					.toString());
		}
		return;
	}

	public void procFieldGroupData(int iKeyIndex, Vector vAddReportItem,
			Vector vFieldGroup, String sTitle, String sSubTitle,
			String saColKey[], String saColTitle[], boolean bRetTopLevel,
			ArrayList alOtherParam) {
		if (sTitle == null || saColTitle == null || saColTitle.length == 0
				|| saColKey == null || saColKey.length != saColTitle.length
				|| vAddReportItem == null || vFieldGroup == null) {
			SCMEnv.out("param null");
			return;
		}
		ReportItem riTemp = null;
		if (iKeyIndex >= 0)
			riTemp = getReportItem((new StringBuilder()).append(saColKey[0])
					.append(iKeyIndex).toString(), saColTitle[0]);
		else
			riTemp = getReportItem(saColKey[0], saColTitle[0]);
		vAddReportItem.addElement(riTemp);
		int iColNum = saColTitle.length;
		FldgroupVO voFg = null;
		if (iColNum == 1) {
			voFg = new FldgroupVO();
			voFg.setGroupid(new Integer(0));
			voFg.setItem1((new StringBuilder()).append("").append(
					vAddReportItem.size() - 1).toString());
			voFg.setItem2(sSubTitle);
			voFg.setGrouptype("1");
			if (bRetTopLevel)
				voFg.setToplevelflag("Y");
			else
				voFg.setToplevelflag("N");
			voFg.setGroupname(sTitle);
			vFieldGroup.addElement(voFg);
			return;
		}
		if (iColNum > 1) {
			if (iKeyIndex >= 0)
				riTemp = getReportItem((new StringBuilder())
						.append(saColKey[1]).append(iKeyIndex).toString(),
						saColTitle[1]);
			else
				riTemp = getReportItem(saColKey[1], saColTitle[1]);
			vAddReportItem.addElement(riTemp);
			voFg = new FldgroupVO();
			voFg.setGroupid(new Integer(0));
			voFg.setItem1((new StringBuilder()).append("").append(
					vAddReportItem.size() - 1).toString());
			voFg.setItem2((new StringBuilder()).append("").append(
					vAddReportItem.size() - 2).toString());
			voFg.setGrouptype("0");
			if (iColNum == 2 && bRetTopLevel && sTitle.equals(sSubTitle))
				voFg.setToplevelflag("Y");
			else
				voFg.setToplevelflag("N");
			voFg.setGroupname(sSubTitle);
			vFieldGroup.addElement(voFg);
			if (iColNum == 2 && bRetTopLevel && sTitle.equals(sSubTitle))
				return;
		}
		for (int col = 2; col < iColNum; col++) {
			if (iKeyIndex >= 0)
				riTemp = getReportItem((new StringBuilder()).append(
						saColKey[col]).append(iKeyIndex).toString(),
						saColTitle[col]);
			else
				riTemp = getReportItem(saColKey[col], saColTitle[col]);
			vAddReportItem.addElement(riTemp);
			voFg = new FldgroupVO();
			voFg.setGroupid(new Integer(0));
			voFg.setItem1((new StringBuilder()).append("").append(
					vAddReportItem.size() - 1).toString());
			voFg.setItem2(sSubTitle);
			voFg.setGrouptype("1");
			if (col == iColNum - 1 && sTitle.equals(sSubTitle))
				if (bRetTopLevel)
					voFg.setToplevelflag("Y");
				else
					voFg.setToplevelflag("N");
			voFg.setGroupname(sSubTitle);
			vFieldGroup.addElement(voFg);
			if (col == iColNum - 1 && sTitle.equals(sSubTitle))
				return;
		}

		if (sTitle != sSubTitle) {
			int iSearch = 0;
			FldgroupVO voTemporaryField = null;
			for (iSearch = 0; iSearch < vFieldGroup.size(); iSearch++) {
				if (vFieldGroup.elementAt(iSearch) == null)
					continue;
				voTemporaryField = (FldgroupVO) vFieldGroup.elementAt(iSearch);
				if (sTitle.equals(voTemporaryField.getGroupname()))
					break;
			}

			if (iSearch >= vFieldGroup.size()) {
				voFg = new FldgroupVO();
				voFg.setGroupid(new Integer(0));
				voFg.setToplevelflag("N");
				voFg.setItem1(sSubTitle);
				voFg.setItem2(sSubTitle);
				voFg.setGrouptype("3");
				voFg.setGroupname(sTitle);
				vFieldGroup.addElement(voFg);
			} else {
				if (voTemporaryField.getItem1().equals(
						voTemporaryField.getItem2()))
					vFieldGroup.removeElementAt(iSearch);
				voFg = new FldgroupVO();
				voFg.setGroupid(new Integer(0));
				if (bRetTopLevel)
					voFg.setToplevelflag("Y");
				else
					voFg.setToplevelflag("N");
				voFg.setItem1(sSubTitle);
				if (voTemporaryField.getItem1().equals(
						voTemporaryField.getItem2()))
					voFg.setItem2(voTemporaryField.getItem1());
				else
					voFg.setItem2(sTitle);
				voFg.setGrouptype("3");
				voFg.setGroupname(sTitle);
				vFieldGroup.addElement(voFg);
			}
		}
	}

	public void setColShow(boolean bShow, String saCol[]) {
		if (m_voaDefaultRI == null || m_voaDefaultRI.length == 0
				|| saCol == null || saCol.length == 0) {
			SCMEnv.out("no column.");
			return;
		}
		for (int col = 0; col < m_voaDefaultRI.length; col++) {
			if (m_voaDefaultRI[col] == null
					|| m_voaDefaultRI[col].getKey() == null)
				continue;
			for (int ik = 0; ik < saCol.length; ik++)
				if (saCol[ik] != null
						&& saCol[ik]
								.equals(m_voaDefaultRI[col].getKey().trim()))
					m_voaDefaultRI[col].setShow(bShow);

		}

	}

	protected void setScale() {
		BillItem biaCardBody[] = getReportBaseClass().getBodyItems();
		Hashtable htCardBody = new Hashtable();
		for (int i = 0; i < biaCardBody.length; i++)
			htCardBody.put(biaCardBody[i].getKey(), new Integer(i));

		String saBodyNumItemKey[] = { "ntermbeginnum", "nterminnum",
				"ntermoutnum", "ntermonhandnum" };
		for (int k = 0; k < saBodyNumItemKey.length; k++)
			if (htCardBody.containsKey(saBodyNumItemKey[k]))
				biaCardBody[Integer.valueOf(
						htCardBody.get(saBodyNumItemKey[k]).toString())
						.intValue()].setDecimalDigits(m_iaScale[0]);

		String saBodyAstNumItemKey[] = { "nterminastnum", "ntermbeginastnum",
				"ntermoutastnum", "ntermonhandastnum" };
		for (int k = 0; k < saBodyAstNumItemKey.length; k++)
			if (htCardBody.containsKey(saBodyAstNumItemKey[k]))
				biaCardBody[Integer.valueOf(
						htCardBody.get(saBodyAstNumItemKey[k]).toString())
						.intValue()].setDecimalDigits(m_iaScale[1]);

		String saBodyPrice[] = { "nprice", "nplannedprice" };
		for (int k = 0; k < saBodyPrice.length; k++)
			if (htCardBody.containsKey(saBodyPrice[k]))
				biaCardBody[Integer.valueOf(
						htCardBody.get(saBodyPrice[k]).toString()).intValue()]
						.setDecimalDigits(m_iaScale[3]);

		String saBodyMny[] = { "ntermbeginmny", "nterminmny", "ntermoutmny",
				"ntermonhandmny" };
		for (int k = 0; k < saBodyMny.length; k++)
			if (htCardBody.containsKey(saBodyMny[k]))
				biaCardBody[Integer.valueOf(
						htCardBody.get(saBodyMny[k]).toString()).intValue()]
						.setDecimalDigits(m_iaScale[4]);

		if (htCardBody.containsKey("hsl"))
			biaCardBody[Integer.valueOf(htCardBody.get("hsl").toString())
					.intValue()].setDecimalDigits(m_iaScale[2]);
	}

	public void setShowColByQryLevel(char cType) {
		boolean baShow[] = { false, true, true, false, false, false, false,
				false, false, false, false, false, false, false, false, false,
				false };
		switch (cType) {
		case 48: // '0'
			baShow[1] = true;
			baShow[2] = true;
			break;

		case 49: // '1'
		default:
			baShow[4] = true;
			baShow[5] = true;
			baShow[6] = true;
			baShow[7] = true;
			baShow[8] = true;
			break;

		case 50: // '2'
			baShow[4] = true;
			baShow[5] = true;
			baShow[6] = true;
			baShow[7] = true;
			baShow[8] = true;
			baShow[12] = true;
			break;

		case 51: // '3'
			baShow[4] = true;
			baShow[5] = true;
			baShow[6] = true;
			baShow[7] = true;
			baShow[8] = true;
			baShow[13] = true;
			break;

		case 52: // '4'
			baShow[4] = true;
			baShow[5] = true;
			baShow[6] = true;
			baShow[7] = true;
			baShow[8] = true;
			baShow[9] = true;
			baShow[11] = true;
			break;

		case 53: // '5'
			baShow[4] = true;
			baShow[5] = true;
			baShow[6] = true;
			baShow[7] = true;
			baShow[8] = true;
			baShow[9] = true;
			baShow[11] = true;
			baShow[12] = true;
			baShow[13] = true;
			break;

		case 54: // '6'
			baShow[4] = true;
			baShow[5] = true;
			baShow[6] = true;
			baShow[7] = true;
			baShow[8] = true;
			baShow[9] = true;
			baShow[11] = true;
			break;

		case 55: // '7'
			baShow[4] = true;
			baShow[5] = true;
			baShow[6] = true;
			baShow[7] = true;
			baShow[8] = true;
			baShow[9] = true;
			baShow[11] = true;
			baShow[12] = true;
			baShow[13] = true;
			break;
		}
		if (m_voaDefaultRI == null || m_voaDefaultRI.length == 0) {
			SCMEnv.out("no column.");
			return;
		}
		for (int col = 0; col < m_voaDefaultRI.length; col++) {
			if (m_voaDefaultRI[col] == null
					|| m_voaDefaultRI[col].getKey() == null)
				continue;
			for (int ik = 0; ik < m_saAllCol.length; ik++) {
				if (m_saAllCol[ik] == null
						|| !m_saAllCol[ik].equals(m_voaDefaultRI[col].getKey()
								.trim()) || !m_baDefaultShow[ik])
					continue;
				try {
					if (baShow[ik]) {
						m_voaDefaultRI[col].setShow(true);
						getReportBaseClass().showBodyTableCol(m_saAllCol[ik]);
					} else {
						m_voaDefaultRI[col].setShow(false);
						getReportBaseClass().hideBodyTableCol(m_saAllCol[ik]);
					}
				} catch (Exception e) {
				}
			}

		}

	}

	public void setShowGenSumCol(boolean bShow) {
		String saCol[] = { "ntermnum", "ntermastnum", "ntermmny",
				"ntermgrossnum" };
		setColShow(bShow, saCol);
	}

	protected void showTime(long lStartTime, String sTaskHint) {
		long lTime = System.currentTimeMillis() - lStartTime;
		SCMEnv.out((new StringBuilder()).append("\u6267\u884C<").append(
				sTaskHint)
				.append(">\u6D88\u8017\u7684\u65F6\u95F4\u4E3A\uFF1A").append(
						lTime / 60000L).append("\u5206").append(
						(lTime / 1000L) % 60L).append("\u79D2").append(
						lTime % 1000L).append("\u6BEB\u79D2").toString());
	}

	public void splitField(char cGroupType, ArrayList alFieldName) {
		if (m_voaDefaultRI == null || m_voaDefaultRI.length == 0) {
			SCMEnv.out("no column.");
			return;
		}
		try {
			int iShowFieldNum = 3;
			iShowFieldNum = m_bIsAstNumShow ? iShowFieldNum : iShowFieldNum - 1;
			int iFieldCount = 0;
			if (alFieldName != null)
				iFieldCount = alFieldName.size();
			Vector vBillItem = new Vector();
			for (int col = 0; col < m_voaDefaultRI.length; col++)
				if (m_voaDefaultRI[col] != null && m_voaDefaultRI[col].isShow())
					vBillItem.addElement(m_voaDefaultRI[col]);

			ReportItem biAddItem = null;
			int iRdCount = 0;
			int iGroupIdCount = 1;
			Vector vFieldGroup = new Vector();
			FldgroupVO voFg = null;
			String saColTitle[] = new String[iShowFieldNum];
			String saColKey[] = new String[iShowFieldNum];
			saColKey[0] = "nnum";
			saColTitle[0] = NCLangRes.getInstance().getStrByID("common",
					"UC000-0002282");
			int iWhichWrite = 1;
			if (m_bIsAstNumShow) {
				saColKey[iWhichWrite] = "nassistnum";
				saColTitle[iWhichWrite] = NCLangRes.getInstance().getStrByID(
						"common", "UC000-0003971");
				iWhichWrite++;
			}
			saColTitle[iWhichWrite] = ResBase.getMaoZhong();
			saColKey[iWhichWrite] = "ngrossnum";
			iWhichWrite++;
			int col = 0;
			String sColName = null;
			for (int field = 0; field < iFieldCount; field++) {
				if (alFieldName != null && alFieldName.size() > iRdCount
						&& alFieldName.get(field) != null)
					sColName = alFieldName.get(field).toString();
				else
					sColName = NCLangRes.getInstance().getStrByID("4008report",
							"UPP4008report-000159");
				nc.ui.ic.ic641.ClientUI.procFieldGroupData(field, vBillItem,
						vFieldGroup, sColName, sColName, saColKey, saColTitle,
						true, null, m_iaScale);
			}

			vBillItem.addAll(getHiddenBillItem());
			ReportItem riaResult[] = new ReportItem[vBillItem.size()];
			vBillItem.copyInto(riaResult);
			FldgroupVO voaFg[] = new FldgroupVO[vFieldGroup.size()];
			vFieldGroup.copyInto(voaFg);
			getReportBaseClass().setFieldGroup(voaFg);
			getReportBaseClass().setBody_Items(riaResult);
		} catch (Exception e) {
			handleException(e);
		}
		return;
	}

	public Vector getHiddenBillItem() {
		if (m_vBillItemHiddenID == null || m_vBillItemHiddenID.size() == 0) {
			m_vBillItemHiddenID = new Vector();
			for (int i = 0; i < getReportBaseClass().getBody_Items().length; i++)
				if (!getReportBaseClass().getBody_Items()[i].isShow())
					m_vBillItemHiddenID.addElement(getReportBaseClass()
							.getBody_Items()[i]);

		}
		return m_vBillItemHiddenID;
	}

	public String getCorpID() {
		return m_sCorpID;
	}

	protected ArrayList getFormulaItemField(int iLevel, char cGroupType) {
		ArrayList arylistItemField = new ArrayList();
		String aryItemField200[] = { "unitcode", "unitcode", "pk_corp" };
		arylistItemField.add(aryItemField200);
		String aryItemField322[] = { "unitname", "cocorpname", "cocorpid" };
		arylistItemField.add(aryItemField322);
		String aryItemField323[] = { "bodyname", "cocalbodyname", "cocalbodyid" };
		arylistItemField.add(aryItemField323);
		String aryItemField324[] = { "storname", "cowhname", "cowhid" };
		arylistItemField.add(aryItemField324);
		String aryItemField201[] = { "unitname", "unitname", "pk_corp" };
		arylistItemField.add(aryItemField201);
		if (iLevel > 0) {
			String aryItemField20[] = { "pk_invbasdoc", "pk_invbasdoc",
					"cinventoryid" };
			arylistItemField.add(aryItemField20);
			String aryItemField21[] = { "invname", "invname", "pk_invbasdoc" };
			arylistItemField.add(aryItemField21);
			String aryItemField27[] = { "invcode", "cinventorycode",
					"pk_invbasdoc" };
			arylistItemField.add(aryItemField27);
			String aryItemField101[] = { "pk_invcl", "pk_invcl", "pk_invbasdoc" };
			arylistItemField.add(aryItemField101);
			String aryItemField102[] = { "invclasscode", "invclasscode",
					"pk_invcl" };
			arylistItemField.add(aryItemField102);
			String aryItemField103[] = { "invclassname", "invclassname",
					"pk_invcl" };
			arylistItemField.add(aryItemField103);
			String aryItemField22[] = { "invspec", "invspec", "pk_invbasdoc" };
			arylistItemField.add(aryItemField22);
			String aryItemField23[] = { "invtype", "invtype", "pk_invbasdoc" };
			arylistItemField.add(aryItemField23);
			String aryItemField25[] = { "pk_measdoc", "pk_measdoc",
					"pk_invbasdoc" };
			arylistItemField.add(aryItemField25);
			String aryItemField30[] = { "measname", "measdocname", "pk_measdoc" };
			arylistItemField.add(aryItemField30);
			if (iLevel == 4 || iLevel == 5 || iLevel == 6 || iLevel == 7) {
				String aryItemField31[] = { "measname", "castunitname",
						"castunitid" };
				arylistItemField.add(aryItemField31);
			}
		}
		switch (cGroupType) {
		case 48: // '0'
			String aryItemField11[] = { "pk_jobbasfil", "pk_jobbasfil",
					"cfieldid" };
			arylistItemField.add(aryItemField11);
			String aryItemField12[] = { "jobname", "cfieldname", "pk_jobbasfil" };
			arylistItemField.add(aryItemField12);
			break;

		case 49: // '1'
			String aryItemField7[] = { "pk_cubasdoc", "pk_cubasdoc2",
					"cfieldid" };
			arylistItemField.add(aryItemField7);
			String aryItemField8[] = { "custname", "cfieldname", "pk_cubasdoc2" };
			arylistItemField.add(aryItemField8);
			break;

		case 50: // '2'
			String aryItemField15[] = { "storname", "cfieldname", "cfieldid" };
			arylistItemField.add(aryItemField15);
			break;

		case 51: // '3'
			String aryItemField19[] = { "deptname", "cfieldname", "cfieldid" };
			arylistItemField.add(aryItemField19);
			break;

		case 52: // '4'
			String aryItemField3[] = { "psnname", "cfieldname", "cfieldid" };
			arylistItemField.add(aryItemField3);
			break;

		case 53: // '5'
			String aryItemField17[] = { "businame", "cfieldname", "cfieldid" };
			arylistItemField.add(aryItemField17);
			break;

		case 54: // '6'
			String aryItemField18[] = { "rdname", "cfieldname", "cfieldid" };
			arylistItemField.add(aryItemField18);
			break;

		case 55: // '7'
			String aryItemField32[] = { "billtypename", "cfieldname",
					"cfieldid" };
			arylistItemField.add(aryItemField32);
			break;

		case 56: // '8'
			String aryItemField34[] = { "pk_invbasdoc", "ccostobjectbasid",
					"cfieldid" };
			arylistItemField.add(aryItemField34);
			String aryItemField33[] = { "invname", "cfieldname",
					"ccostobjectbasid" };
			arylistItemField.add(aryItemField33);
			break;
		}
		return arylistItemField;
	}

	public String[] getGroupFields(char cGroupType) {
		String saGroupField[] = null;
		switch (cGroupType) {
		case 48: // '0'
			saGroupField = new String[2];
			saGroupField[0] = "invclasscode";
			saGroupField[1] = "pk_corp";
			break;

		case 49: // '1'
		default:
			saGroupField = new String[1];
			saGroupField[0] = "b.cinventoryid";
			break;

		case 50: // '2'
			saGroupField = new String[2];
			saGroupField[0] = "b.cinventoryid";
			saGroupField[1] = "vbatchcode";
			break;

		case 51: // '3'
			saGroupField = new String[11];
			saGroupField[0] = "b.cinventoryid";
			saGroupField[1] = "vfree1";
			saGroupField[2] = "vfree2";
			saGroupField[3] = "vfree3";
			saGroupField[4] = "vfree4";
			saGroupField[5] = "vfree5";
			saGroupField[6] = "vfree6";
			saGroupField[7] = "vfree7";
			saGroupField[8] = "vfree8";
			saGroupField[9] = "vfree9";
			saGroupField[10] = "vfree10";
			break;

		case 52: // '4'
			saGroupField = new String[2];
			saGroupField[0] = "b.cinventoryid";
			saGroupField[1] = "castunitid";
			break;

		case 53: // '5'
			saGroupField = new String[13];
			saGroupField[0] = "b.cinventoryid";
			saGroupField[1] = "castunitid";
			saGroupField[2] = "vbatchcode";
			saGroupField[3] = "vfree1";
			saGroupField[4] = "vfree2";
			saGroupField[5] = "vfree3";
			saGroupField[6] = "vfree4";
			saGroupField[7] = "vfree5";
			saGroupField[8] = "vfree6";
			saGroupField[9] = "vfree7";
			saGroupField[10] = "vfree8";
			saGroupField[11] = "vfree9";
			saGroupField[12] = "vfree10";
			break;

		case 54: // '6'
			saGroupField = new String[3];
			saGroupField[0] = "b.cinventoryid";
			saGroupField[1] = "castunitid";
			saGroupField[2] = "hsl";
			break;

		case 55: // '7'
			saGroupField = new String[14];
			saGroupField[0] = "b.cinventoryid";
			saGroupField[1] = "castunitid";
			saGroupField[2] = "hsl";
			saGroupField[3] = "vbatchcode";
			saGroupField[4] = "vfree1";
			saGroupField[5] = "vfree2";
			saGroupField[6] = "vfree3";
			saGroupField[7] = "vfree4";
			saGroupField[8] = "vfree5";
			saGroupField[9] = "vfree6";
			saGroupField[10] = "vfree7";
			saGroupField[11] = "vfree8";
			saGroupField[12] = "vfree9";
			saGroupField[13] = "vfree10";
			break;
		}
		return saGroupField;
	}

	public AggregatedValueObject getReportVO() {
		return m_voReport;
	}

	public String getUserID() {
		return m_sUserID;
	}

	public void scanField(String saGroupField[], InOutSumItemVO voaItem[],
			Hashtable htFieldInOut, ArrayList alFieldNameInOut) {
		if (saGroupField == null || saGroupField.length == 0 || voaItem == null
				|| voaItem.length == 0 || htFieldInOut == null
				|| alFieldNameInOut == null) {
			SCMEnv.out("@@@param null.");
			return;
		}
		StringBuffer sbGroupString = new StringBuffer();
		Object oTempField = null;
		Object oTempID = null;
		Object oTempName = null;
		String sLastGroup = null;
		String sLastFieldtype = null;
		int iFieldCount = 0;
		boolean bHaveFieldInOutNullID = false;
		for (int row = 0; row < voaItem.length; row++) {
			if (voaItem[row] == null)
				continue;
			oTempID = voaItem[row].getAttributeValue("cfieldid");
			oTempName = voaItem[row].getAttributeValue("cfieldname");
			if (oTempID == null || oTempID.toString().trim().length() == 0) {
				oTempID = InOutSumItemVO.RD_NULL_ID;
				oTempName = InOutSumItemVO.RD_NULL_NAME;
			}
			if (oTempID != null
					&& !htFieldInOut.containsKey(oTempID.toString().trim())) {
				htFieldInOut.put(oTempID.toString().trim(), new Integer(
						iFieldCount));
				alFieldNameInOut.add(oTempName);
				iFieldCount++;
			}
		}

		if (iFieldCount > 1 && voaItem.length > 1) {
			alFieldNameInOut.add(NCLangRes.getInstance().getStrByID("common",
					"UC000-0001146"));
			iFieldCount++;
		}
	}

	protected void setReportData(char cGroupType, InOutSumItemVO reportData[],
			String sQryLevel) {
		if (sQryLevel == null)
			return;
		int iLevel = Integer.parseInt(sQryLevel);
		ArrayList arylistItemField = getFormulaItemField(iLevel, cGroupType);
		long lTime = System.currentTimeMillis();
		setBodyDatabyFormulaItem(reportData, arylistItemField, true);
		if (iLevel == 4 || iLevel == 5 || iLevel == 6 || iLevel == 7)
			InvoInfoBYFormula.getInVoOfHSL(reportData, "pk_invbasdoc",
					"pk_measdoc", "castunitid", "hsl", "fixedflag");
		if (iLevel == 3 || iLevel == 5 || iLevel == 7) {
			FreeVOParse freeVOParse = new FreeVOParse();
			freeVOParse.setFreeVO(reportData, "pk_invbasdoc", null, true);
		}
		showTime(lTime, (new StringBuilder()).append(
				"\u516C\u5F0F\u89E3\u6790\u67E5\u8BE2").append(
				reportData.length).append("\u6761").toString());
		lTime = System.currentTimeMillis();
		ArrayList alRetReNew = splitFieldType(sQryLevel.charAt(0), reportData);
		showTime(lTime, "\u62C6\u5206\u5E76\u5408\u8BA1VO");
		if (alRetReNew != null && alRetReNew.size() >= 2) {
			ArrayList alFieldName = (ArrayList) alRetReNew.get(1);
			InOutSumItemVO voaF[] = (InOutSumItemVO[]) (InOutSumItemVO[]) alRetReNew
					.get(0);
			lTime = System.currentTimeMillis();
			splitField(' ', alFieldName);
			showTime(lTime, "\u62A5\u8868\u5217\u91CD\u65B0\u7EC4\u5408");
			getReportBaseClass().setBodyDataVO(voaF, true);
		}
	}

	public ArrayList splitFieldType(char cGroupType, InOutSumItemVO voaItem[]) {
		if (voaItem == null || voaItem.length == 0) {
			return null;
		} else {
			String saGroupField[] = getGroupFields(cGroupType);
			Hashtable htFieldInOut = new Hashtable();
			ArrayList alFieldNameInOut = new ArrayList();
			String sSplitfieldname = null;
			scanField(saGroupField, voaItem, htFieldInOut, alFieldNameInOut);
			InOutSumItemVO voaRetItems[] = sumField(saGroupField, voaItem,
					htFieldInOut);
			ArrayList alRet = new ArrayList();
			alRet.add(voaRetItems);
			alRet.add(alFieldNameInOut);
			return alRet;
		}
	}

	public InOutSumItemVO[] sumField(String saGroupField[],
			InOutSumItemVO voaItem[], Hashtable htFieldInOut) {
		if (saGroupField == null || saGroupField.length == 0 || voaItem == null
				|| voaItem.length == 0 || htFieldInOut == null
				|| htFieldInOut.size() == 0) {
			SCMEnv.out("@@@param null.");
			return null;
		}
		StringBuffer sbGroupString = new StringBuffer();
		Object oTempField = null;
		Object oTempID = null;
		Object oTempName = null;
		String sLastGroup = null;
		String sLastFieldtype = null;
		int iFieldCount = htFieldInOut.size();
		boolean bHaveFieldInOutNullID = false;
		InOutSumItemVO voFieldSum = null;
		Vector vTempItem = new Vector();
		double dTermsumnum = 0.0D;
		double dTermsumastnum = 0.0D;
		double dTermsummny = 0.0D;
		double dTermsumgrossnum = 0.0D;
		int iIdIndex = -1;
		UFDouble dTemp = null;
		FieldSumVO voSum = null;
		for (int row = 0; row < voaItem.length; row++) {
			if (voaItem[row] == null)
				continue;
			sbGroupString = new StringBuffer();
			for (int gf = 0; gf < saGroupField.length; gf++) {
				oTempField = voaItem[row].getAttributeValue(saGroupField[gf]);
				if (oTempField == null
						|| oTempField.toString().trim().length() == 0)
					sbGroupString.append(InOutSumItemVO.RD_NULL_ID);
				else
					sbGroupString.append(oTempField.toString().trim());
			}

			if (row == 0) {
				sLastGroup = sbGroupString.toString();
				voFieldSum = (InOutSumItemVO) voaItem[row].clone();
				if (iFieldCount > 1)
					voFieldSum.initDataSize(iFieldCount + 1);
				else
					voFieldSum.initDataSize(iFieldCount);
			}
			if (!sbGroupString.toString().equals(sLastGroup)) {
				if (iFieldCount >= 2) {
					voSum = new FieldSumVO();
					voSum.setNnum(new UFDouble(dTermsumnum));
					voSum.setNassistnum(new UFDouble(dTermsumastnum));
					voSum.setNmny(new UFDouble(dTermsummny));
					voSum.setAttributeValue("ngrossnum", new UFDouble(
							dTermsumgrossnum));
					voFieldSum.setFieldType(iFieldCount, voSum);
				}
				vTempItem.add(voFieldSum);
				voFieldSum = (InOutSumItemVO) voaItem[row].clone();
				if (iFieldCount > 1)
					voFieldSum.initDataSize(iFieldCount + 1);
				else
					voFieldSum.initDataSize(iFieldCount);
				dTermsumnum = 0.0D;
				dTermsumastnum = 0.0D;
				dTermsummny = 0.0D;
				dTermsumgrossnum = 0.0D;
				iIdIndex = -1;
				sLastGroup = sbGroupString.toString();
			}
			voSum = new FieldSumVO();
			oTempID = voaItem[row].getCfieldid();
			if (oTempID == null || oTempID.toString().trim().length() == 0)
				oTempID = InOutSumItemVO.RD_NULL_ID;
			oTempID = oTempID.toString().trim();
			voSum.setFieldsumid(oTempID.toString());
			try {
				iIdIndex = Integer
						.valueOf(htFieldInOut.get(oTempID).toString())
						.intValue();
			} catch (Exception e) {
				SCMEnv.out("cannot get name");
			}
			dTemp = new UFDouble(toDouble(voaItem[row].getNtermnum()));
			voSum.setNnum(dTemp);
			dTermsumnum += dTemp.doubleValue();
			dTemp = new UFDouble(toDouble(voaItem[row].getNtermastnum()));
			voSum.setNassistnum(dTemp);
			dTermsumastnum += dTemp.doubleValue();
			dTemp = new UFDouble(toDouble(voaItem[row].getNtermmny()));
			voSum.setNmny(dTemp);
			dTermsummny += dTemp.doubleValue();
			dTemp = new UFDouble(toDouble(voaItem[row]
					.getAttributeValue("ntermgrossnum")));
			voSum.setAttributeValue("ngrossnum", dTemp);
			dTermsumgrossnum += dTemp.doubleValue();
			voFieldSum.setFieldType(iIdIndex, voSum);
		}

		if (iFieldCount >= 2) {
			voSum = new FieldSumVO();
			voSum.setNnum(new UFDouble(dTermsumnum));
			voSum.setNassistnum(new UFDouble(dTermsumastnum));
			voSum.setNmny(new UFDouble(dTermsummny));
			voSum
					.setAttributeValue("ngrossnum", new UFDouble(
							dTermsumgrossnum));
			voFieldSum.setFieldType(iFieldCount, voSum);
		}
		vTempItem.add(voFieldSum);
		InOutSumItemVO voaRetItems[] = null;
		if (vTempItem.size() > 0) {
			voaRetItems = new InOutSumItemVO[vTempItem.size()];
			vTempItem.copyInto(voaRetItems);
		}
		return voaRetItems;
	}

	protected double toDouble(Object o) {
		try {
			return (new Double(o.toString())).doubleValue();
		} catch (Exception e) {
			return 0.0D;
		}
	}

	public IcBaseReportComm getIcBaseReportComm() {
		if (m_IcBaseReportComm == null)
			m_IcBaseReportComm = new IcBaseReportComm();
		return m_IcBaseReportComm;
	}

	protected ReportBaseClass ivjReportBaseClass;

	protected ButtonObject m_boQuery;

	protected ButtonObject m_aryButtonGroup[];

	protected String m_sCorpID;

	protected String m_sCorpName;

	protected String m_sUserID;

	protected String m_sLogDate;

	protected String m_sUserName;

	protected ICMultiCorpQryClient m_QueryConditionDlg;

	protected String m_sQTempletID;

	protected int m_iDispMode;

	protected int m_iMnyType;

	protected boolean m_bIsAstNumShow;

	protected String m_sInOut;

	protected FldgroupVO m_voaDefaultFld[];

	protected ReportItem m_voaDefaultRI[];

	protected boolean m_baDefaultShow[];

	protected String m_saAllCol[] = { "pk_invcl", "invclasscode",
			"invclassname", "cinventoryid", "cinventorycode", "invname",
			"invspec", "invtype", "measdocname", "hsl", "castunitid",
			"castunitname", "vbatchcode", "vfree0", "cdispatcherid",
			"cdispatchername", "rdflag" };

	protected String m_sPNodeCode;

	protected AggregatedValueObject m_voReport;

	protected String m_sHeaderVOName;

	protected String m_sItemVOName;

	protected String m_sVOName;

	protected int m_iaScale[] = { 2, 2, 2, 2, 2 };

	public static final int SC_NUM = 0;

	public static final int SC_ASTNUM = 1;

	public static final int SC_CONVRATE = 2;

	public static final int SC_PRICE = 3;

	public static final int SC_MNY = 4;

	protected Vector m_vBillItemHiddenID;

	IcBaseReportComm m_IcBaseReportComm;
}
